package com.aloaproject.ciquta;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * This is the base class for {@link Criterion crioterions} that combine other {@link Criterion crioterion}.
 * @author Daniele Demichelis
 */
public abstract class MultipleCriterion implements Criterion {

    private final ArrayList<Criterion> criterions;

    MultipleCriterion() {
        this(new Criterion[]{});
    }

    MultipleCriterion(final Criterion... criterions) {
        if(criterions == null){
            throw new RuntimeException("Criterions cannot be null.");
        }
        this.criterions = new ArrayList<Criterion>();
        this.criterions.addAll( Arrays.asList(criterions) );
    }

    MultipleCriterion add(final Criterion criterion) {
        this.criterions.add(criterion);
        return this;
    }

    protected List<Criterion> getCriterions(){
        return this.criterions;
    }

}
